import React, { Component } from "react";

export default class Ccpn extends Component {
  constructor(props) {
    super(props);
    this.state = {
      counter: 0,
    };
  }
  render() {
    return (
      <div>
        <h2>当前计数:{this.state.counter}</h2>
        {/* <button onClick={this.increment.bind(this)}>+1</button>
        <button onClick={this.decrement.bind(this)}>-1</button> */}
        {/* <button onClick={this.increment}>+1</button>
        <button onClick={this.decrement}>-1</button> */}
        <button
          onClick={() => {
            this.increment();
          }}
        >
          +1
        </button>
        <button
          onClick={() => {
            this.decrement();
          }}
        >
          -1
        </button>
        <button
          onClick={(e) => {
            this.getParam("fsy", 20, e);
          }}
        >
          获取参数
        </button>
      </div>
    );
  }
  //   increment() {
  //     // 继承的Component中有setState方法
  //     this.setState({
  //       counter: this.state.counter + 1,
  //     });
  //   }
  //   decrement() {
  //     this.setState({
  //       counter: this.state.counter - 1,
  //     });
  //   }

  increment = () => {
    console.log(this);
  };
  decrement = () => {
    console.log(this);
  };

  getParam(name, age, e) {
    console.log(name, age, e);
  }
}
